<?php
class SearchController extends HomeController{
	
	public function actionIndex(){
		$keyword = Yii::app()->request->getParam('keyword');
		
		$cdb = new CDbCriteria();
		$cdb->select = 'title,article_id,post_time';
		$cdb->condition = 'title like "%'.$keyword.'%"';
		
		$count = Article::model()->count($cdb);
		
		//分页限制查询条件
		$pager = new CPagination($count);
		$pager->pageSize = 34;
		$pager->applyLimit($cdb);	//对查询条件标准进行限制
		
		$list = Article::model()->findAll($cdb);

		//print_r($list);
		

		$this->render('index', array('list'=>$list, 'pages'=>$pager));
	}
}